package easystudy.admin;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.RedirectView;

import easystudy.dao.BoardDao;
import easystudy.dao.MemberDao;
import easystudy.dto.Board;

@Controller
public class DetailController {

	private BoardDao boardDao;
	
	private MemberDao memberDao;
	
	public void setBoardDao(BoardDao boardDao){
		this.boardDao = boardDao;
	}
	
	public void setMemberDao(MemberDao memberDao){
		this.memberDao = memberDao;
	}
	
	@RequestMapping(value="/board_detail.ad", method=RequestMethod.GET)
	public ModelAndView doSendDetail(@RequestParam("board_num")int board_num, 
			@RequestParam("member_num")int member_num, HttpServletRequest req){
		
		String link = null;
		
		switch(boardDao.getBoardDetail(board_num).getCategory()){
		case 1 : link="java_detail.ja?board_num="+board_num+"&member_num="+member_num; break;	
		case 2 : link="db_detail.db?board_num="+board_num+"&member_num="+member_num; break;	
		case 3 : link="js_detail.bo?board_num="+board_num+"&member_num="+member_num; break;	
		case 4 : link="fr_detail.fr?board_num="+board_num+"&member_num="+member_num; break;	
		default : link="no_detail.no?board_num="+board_num+"&member_num="+member_num; break;
		}
		
		return new ModelAndView(new RedirectView(link));
	}
	
}
